<!--
 * @Author: your name
 * @Date: 2021-05-24 10:34:35
 * @LastEditTime: 2021-05-24 14:57:07
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \5.24\dan\src\views\Login.vue
-->
<template>
  <div class="login">
    <el-form label-width="100px" class="demo-ruleForm">
      <el-form-item label="用户名" prop="user">
        <el-input type="text" v-model="user" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item label="密码" prop="pwd">
        <el-input type="password" v-model="pwd" autocomplete="off"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="BtnLogin">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      user: "",
      pwd: "",
    };
  },
  methods: {
    async BtnLogin() {
      let res = await axios.post("/api/login", {
        user: this.user,
        pwd: this.pwd,
      });
      if (res.data.code === 200) {
        window.localStorage.setItem("user", this.user);
        this.$router.push("/Two");
      }
    },
  },
};
</script>

<style>
.login {
  width: 350px;
  height: 200px;
  margin: 0 auto;
  border: 3px dashed turquoise;
}
</style>